Skip to content

DEV-1275: over BLE too, report a Shimmer ready only once its connect sequence has ended - #137

Merged
JongChern merged 1 commit into
masterfrom
DEV-1275_android_ble_ready_after_connect_sequence
Oct 23, 2026
Merged

JongChern merged 1 commit into
masterfrom
DEV-1275_android_ble_ready_after_connect_sequence

Conversation

@JongChern

Copy link
Copy Markdown
Contributor

DEV-1275 over BLE. #132 ports the driver's fix to Shimmer, the Classic class. The Android HIL found the same defect in Shimmer3BLEAndroid: a Shimmer3R over BLE was reported ready about 3 s before its connect sequence ended. That was with driver 0.11.11_beta, which can't fix it, because Shimmer3BLEAndroid overrides the code involved.

The bug, in two places

  • On connect: as soon as the BLE notifications came on, onNotifyEnabled() sent the app a CONNECTED state message, before initialize() had even queued the connect sequence.
  • On a status reply: like Shimmer, it overrides the status handler. A status reply part way through the sequence moved the state on: to SDLOGGING for a logging unit, which also sets mIsInitialised, and to CONNECTED once connected.

An app that takes either as ready sends its own commands in among the rest of the connect sequence. In the Java driver, that's how a configure cut a Shimmer3's calibration dump short and left its accel NaN.

The fix

  • When the notifications come on, the state is CONNECTING.
  • While CONNECTING, a status reply leaves the state alone.
  • The sequence's own end, isReadyForStreaming(), reports the unit ready: SDLOGGING for a unit whose status showed it logging (the callback adapter only moves CONNECTING to CONNECTED), otherwise CONNECTED as before.

Tested

  • AAPI_00006_BleConnectReadyAfterConnectSequenceTest hands a status reply to the driver's parser while CONNECTING. Without the fix, the idle case reports Ready and the logging case SD Logging before the sequence ends; with it, both wait for the end. A third case checks a status reply still moves the state once connected.
  • Android HIL connectReady on s3r-2f31 (Shimmer3R, LogAndStream v1.1.22) over BLE, driver 0.11.11_beta, from an M2101K6G phone on Android 11:
Build Idle connect: reported ready this long before the connect sequence ended
without this PR 2945 ms, then 3016 ms: fails, limit 250 ms
with this PR -7 ms, then -3 ms: ready just after the sequence's end, passes

Not tested yet: the connect to a logging unit. 2F31 was charging over USB-C and doesn't log while plugged in. I'll test that part unplugged.

🤖 Generated with Claude Code

…equence has ended

The Android HIL's connectReady found a Shimmer3R over BLE reported ready
2.7 s before its connect sequence ended, with driver 0.11.11_beta. #132
ports the driver's fix to Shimmer, the Classic class; Shimmer3BLEAndroid had
the same defect, in two places:
- it sent the app a CONNECTED state message as soon as the BLE
  notifications were on, before initialize() queued the connect sequence;
- like Shimmer, it overrides the status handler, and a status reply part
  way through the sequence moved the state on: to SDLOGGING for a logging
  unit, which also sets mIsInitialised, and to CONNECTED once connected.

When the notifications come on, the state is now CONNECTING. While
CONNECTING, a status reply leaves the state alone. The sequence's own end,
isReadyForStreaming(), reports the unit ready: SDLOGGING for a unit the
status showed logging, since the callback adapter only moves CONNECTING to
CONNECTED.

AAPI_00006 hands a status reply to the driver's parser while CONNECTING.
Without the fix the idle case reports Ready and the logging case SD Logging
before the sequence ends; with it both wait for the end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern
JongChern merged commit 0dfea5d into master Oct 23, 2026
1 check passed
@JongChern
JongChern deleted the DEV-1275_android_ble_ready_after_connect_sequence branch October 23, 2026 13:23
@JongChern

Copy link
Copy Markdown
Contributor Author

Logging connect verified too (24 Oct)

connectReady in full on s3r-2f31 (Shimmer3R v1.1.22) over BLE, now unplugged so it can log. Both builds use driver 0.11.11_beta, from an M2101K6G phone on Android 11.

Build Idle connect: reported ready this early Connect while logging: reported ready this early
master with this PR reverted 2753 ms, then 2630 ms: fails 2583 ms, then 2784 ms: fails
master -3 ms, then -3 ms: passes 0 ms, then 0 ms: passes, and the connect ends in SD Logging

The isReadyForStreaming() change does its job: a unit found logging ends its connect in SD Logging rather than Ready.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant